/**
 * Created by USER on 2017/11/7.
 */
'use strict';
var gulp = require('gulp'),
    gulpLoadPlugins = require('gulp-load-plugins'),
    plugins = gulpLoadPlugins(),
    browserSync = require('browser-sync').create(),
    reload = browserSync.reload;
//对html进行处理
gulp.task('html',[],function () {
    gulp.src('src/*.html')
        .pipe(gulp.dest('dist/'));
});

//对js进行处理
gulp.task('js',[],function () {

});

gulp.task('less',function () {
    gulp.src('src/less/*.less')
        .pipe(plugins.less())
        .pipe(gulp.dest('dist/css/'))
        .pipe(reload({stream:true}));

});

//对css进行处理
gulp.task('css',[],function () {
    gulp.src('src/css/*.*')
        .pipe(gulp.dest('dist/css/'))
        .pipe(reload({stream:true}));
});

gulp.task('html-watch',[],browserSync.reload);

gulp.task('serve',[],function () {
    browserSync.init({
        server: "./dist/"
    });
    gulp.watch('src/css/*.*',['css']);
    gulp.watch('src/less/*.less',['less']);
    gulp.watch('src/*.html',['html']);
    gulp.watch('dist/*.html').on('change',reload);
    gulp.watch('dist/css/*.css').on('change',reload);
});

gulp.task('default',['serve']);


